
#ifndef GRID
#define GRID

#include "position.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#define NORTH 1
#define SOUTH 2
#define EAST 3
#define WEST 4
#define GRID_SIZE 40

using namespace std;

namespace Group5 {

class Grid {

  public:

  Position position;
  Grid * north;
  Grid * south;
  Grid * east;
  Grid * west;

  bool has_robot;
  bool isstart;
  bool explored;

  Grid();
  Grid( int px, int py );
  ~Grid();

  void set_explored();
  const bool is_explored();
  Grid& add_grid( int direction );
  void add_grid( int direction, Grid * g );
  bool is_free( int direction ) const;
  Grid* get_grid( int direction ) const;
  int get_x() const { return position.x; }
  int get_y() const { return position.y; }
  const Position& get_position() const { return position; }

  void enter() { has_robot = true; }
  void leave() { has_robot = false; }
  void set_start() { isstart = true; }
  const bool is_start() { return isstart; }

  friend ostream & operator<<( ostream &out, const Grid & g ) {
    out << "( " << g.get_x() << ", " << g.get_y() << " )";
    return out;
  }

  const bool operator==( Grid const & ) const;
  const bool operator<( Grid const & ) const;

};

};

#endif
